import { defineStore } from "pinia";
import { store } from "@/store";
import { metaTableRow } from "./types";

export const useMetaStateRow = defineStore({
  id: "metaTable-store",
  state: (): metaTableRow => ({
    // 用户名
    id: 0,
    // 页面级别权限
    tableName: "",
    tableJson: ""
  }),
  getters: {
    getID(state) {
      return state.id;
    },
    getTableName(state) {
      return state.tableName;
    },
    getTableJson(state) {
      return state.tableJson;
    }
  },
  actions: {
    /** 存储用户名 */
    SET_METAROW(id: number, tableName: string, json: string) {
      this.id = id;
      this.tableName = tableName;
      this.tableJson = json;
    }
  }
});

export function useMetaStateRowHook() {
  return useMetaStateRow(store);
}
